#pragma once

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

class Thread
{
public:
	typedef unsigned int (__stdcall *ThreadHandle)(void*);
	enum PriorityType
	{
		Priority_Normal,
		Priority_Suspend,
	};
	enum StateType
	{
		State_None,
		State_Suspend,
		State_Run,
		State_Final,
	};

public:
	Thread();
	~Thread();

	bool Start(ThreadHandle handle, void *param, unsigned int stack_size = 0, PriorityType priority = Priority_Normal);
	void Final();
	void Suspend();
	void Resume();

	bool CheckFinal() const;

private:
	void Join();

private:
	HANDLE mThread;
	StateType mState;
};

// inline methords of Thread
inline bool Thread::CheckFinal() const
{
	return mState == State_Final;
}
